package autobattle

import (
	"autobattle/battle_map"
	"autobattle/battle_obj"
	"autobattle/builder"
	"autobattle/context"
	"autobattle/event"
)

// NextTurn 推进下一帆
func NextTurn() {
	event.GetMediatorInstance().Notify(event.BeforeEnterTurn, nil)
	event.GetMediatorInstance().Notify(event.EnterTurn, nil)
	event.GetMediatorInstance().Notify(event.AfterEnterTurn, nil)
}

// NewBattle 创建一场战斗
func NewBattle(p1 []battle_obj.BattleProperty, p2 []battle_obj.BattleProperty, battleMap battle_map.BattleMap, battleId int64) {
	battleContext := context.NewContext()
	battleContext.BattleMap = &battleMap
	battleContext.BattleID = battleId
	characterBuilder := builder.CharacterBuilder{}
	t1 := characterBuilder.BuildCharacter(p1, battleContext)
	t2 := characterBuilder.BuildCharacter(p2, battleContext)
	battleContext.T1 = t1
	battleContext.T2 = t2
}

// StartBattle 开始战斗
func StartBattle() {
	event.GetMediatorInstance().Notify(event.BeginBattle, nil)
}
